package com.vint.mi;


/**
 * 第一个缺失的正数，数列中
 */
public class Mi6 {
    public static String solution(String line){
        String[] src = line.split(",");
        int l1 = src[0].length();
        int l2 = src[1].length();
        int l3 = src[2].length();
        char[] a1 = src[0].toCharArray();
        char[] a2 = src[1].toCharArray();
        char[] a3 = src[2].toCharArray();
        return String.valueOf(isMatch(a1,a2,a3,l1,l2));
    }

    public static boolean isMatch(char[]a, char[] b, char[] c, int m, int n){
    	if(m==0&&n==0)return true;
	    if(n==0&&a[m-1]==c[m-1])return isMatch(a,b,c,m-1,0);
	    if(m==0&&a[n-1]==c[n-1])return isMatch(a,b,c,0,n-1);
    	//if(a[m-1]==c[m+n-1])return isMatch(a,b,c,m-1,n);
	    //if(b[n-1]==c[m+n-1])return isMatch(a,b,c,m,n-1);
	    if(a[m-1]==c[m+n-1]||b[n-1]==c[m+n-1])return isMatch(a,b,c,m-1,n)||isMatch(a,b,c,m,n-1);
	    return false;
    }

    public static void main(String[] args) {
        System.out.println(solution("aabcc,dbbca,aadbbbaccc"));
	    System.out.println(solution("abc,bca,aabbcc"));
	    System.out.println(solution("abc,bca,bcaabc"));
    }
}
